<h2 class="title"><?php echo $titlepage?></h2>
<p><?php echo __l('>> Give us a little more info to help improve your experience.')?></p>

<?php echo $form->create('Subscription',array('action'=>'info','class'=>'normal'))?>
<?php echo $form->hidden('email',array('value'=>$email))?>
<fieldset style="display: none;"><?php echo $form->input('cities_remove',array('id'=>'cities_remove','value'=>''))?></fieldset>
<fieldset class="form-block round-5">
    <legend><?php echo __l('Manage which emails you receive')?></legend>
    
    <p><?php echo __l('To unsubscribe from an email, uncheck the applicable box and click "submit changes." ')?></p>
    
    <div class="signed-up-head">
        <div class="clearfix city-head float"> <a class="new-city-link float" onclick="showCityList()">Add New Cities</a> <a class="new-city-arrow float" onclick="showCityList()"></a> </div>
        
        <div class="city-all-list clear" style="display: none;" id="city_list"> <a onclick="showCityList(true)" class="close-x"></a>
            <ul class="">
            <?php      
            foreach($cities as $city_id => $city_name) 
            {
                if (in_array($city_id, $se_cities_user)) {
                    ?>
                    <li style="color:grey"><?php echo $city_name; ?></li>
                    <?php
                } else {
                    ?>
                    <li class="city_name_in_list" id="<?php echo $city_id ?>"><?php echo $city_name; ?></li>
                    <?php
                }
            }
            ?>
            </ul>
            <div class="clear"></div>
        </div>
        
        <div class="clearfix city-list clear" id="user_cities_list">
            <?php 
            echo $form->input('city_id',array('multiple'=>'checkbox','options'=>$cities_user,'selected'=>$se_cities_user,'label'=>false));
            
            ?>      
            <div class="clear"></div>
        </div>
    </div>
</fieldset>

<fieldset class="form-block round-5">
    <legend><?php echo __l('Manage your interests')?></legend>
    <p><?php echo __l('This will help us focus on getting deals in the categories that matter most to people, and over time we\'ll also aim to customize the emails we send you with this info. ')?></p>
    
    <div class="interest-list clearfix">
        <?php
        echo $form->input('UserCategory.category_id',array('multiple'=>'checkbox','options'=>$categories,'selected'=>$user_interests,'label'=>false));
        ?>
    </div>
</fieldset>

<?php if(!$auth->user('id')):?>
<fieldset class="form-block round-5">
    <legend><?php echo __l('Account information')?></legend>
    
    <?php 
    echo $form->input('User.username',array('info' => __l('Must start with an alphabet. <br/> Must be minimum of 3 characters and <br/> Maximum of 20 characters <br/> No special characters and spaces allowed'),'label' => __l('Username')));
	echo $form->input('User.email',array('label' => __l('Email'),'value'=>$email));
	echo $form->input('User.referred_by_user_id',array('type' => 'hidden',));
	if(empty($this->data['User']['openid_url']) && empty($this->data['User']['fb_user_id']) && empty($this->data['User']['twitter_user_id'])):
		echo $form->input('User.passwd', array('label' => __l('Password')));
		echo $form->input('User.confirm_password', array('type' => 'password', 'label' => __l('Password Confirmation')));
		echo $form->input('User.type',array('type' => 'hidden', 'value' => $type));
	endif;
    ?>
</fieldset>
<?php endif;?>
<?php /*
<fieldset class="form-block round-5">
    <legend><?php echo __l('Other information')?></legend>
    <p><?php echo __l('This will help us personalize your emails and website experience in the future. We won\'t share this info with anyone. ')?></p>
    
    
</fieldset>
*/?>
<?php echo $form->end(__l('Submit change'));?>
<div class="clear"></div>
<script>
function showCityList()
{
    if($("#city_list").is(':visible')){
        $("#city_list").slideUp('fast');
    }
    else{
        $("#city_list").slideDown('fast');
    }
}
$(document).ready(function() {
	$(".city_name_in_list").click(function () { 
	   if($(this).css('color')!='grey')
       {
            var htmlTemp = '<div class="checkbox">' +
                        '<input type="checkbox" checked="checked" value="' + 
                        $(this).attr("id") + 
                        '" name="data[Subscription][city_id][]" />' +
                       '<label>' + $(this).html() + '</label></div>';
            $("#user_cities_list .select").append(htmlTemp);
       }
        $(this).css('color','grey');
    });
    $("#user_cities_list .select input").click(function () { 
        var oldvl = $('#cities_remove').val();
        $('#cities_remove').val(oldvl.replace($(this).val() + ',',''));
        if ($(this).attr('checked') == false) {
            $('#cities_remove').val(oldvl + $(this).val() + ',');
        }
    });
});
</script>

